﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Globalization;

namespace NUS.ISS.ARS.Web.Helper
{
    public class PageHelper
    {
        public const string DATE_FORMAT_DEFAULT = "d/M/yyyy";
        public static string FormatDateTimeDefault(DateTime dateTime)
        {
            if (dateTime != null)
            {
                return dateTime.ToString(DATE_FORMAT_DEFAULT);
            }

            return string.Empty;
        }

        public static DateTime? ConvertStringToDateTImeDefault(string dateTimeString)
        {
            CultureInfo provider = CultureInfo.InvariantCulture;
            try
            {
                return DateTime.ParseExact(dateTimeString, DATE_FORMAT_DEFAULT, provider);
                
            }
            catch (FormatException)
            {
                //Log Error
                return null;
            } 
        }
    }
}